package com.bnz.manager.controller;

import java.util.Arrays;
import java.util.Map;

import com.bnz.manager.group.Specification;
import com.bnz.utils.PageUtils;
import com.bnz.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bnz.manager.entity.SpecificationEntity;
import com.bnz.manager.service.SpecificationService;



@RestController
@RequestMapping("specification")
public class SpecificationController {
    @Autowired
    private SpecificationService specificationService;

    /**
     * 列表
     */
    @GetMapping("/list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = specificationService.queryPage(params);

        return R.ok().put("page", page);
    }
    @GetMapping("/findAll")
    public R findAll(){
     return  R.ok().put("list",specificationService.list());
    }

    /**
     * 信息
     */
    @GetMapping("/info/{id}")
        public R info(@PathVariable("id") String id){
		Specification specification = specificationService.findById(id);

        return R.ok().put("specification", specification);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
        public R save(@RequestBody Specification specification){
        System.out.println("specification = " + specification);
		specificationService.save(specification);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
        public R update(@RequestBody Specification specification){
		specificationService.update(specification);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
        public R delete(@RequestBody String[] ids){
		specificationService.deleteAll(Arrays.asList(ids));

        return R.ok();
    }


}
